// ** React Imports
import { useContext, useEffect, useRef } from 'react'
import * as echarts from 'echarts'

const LeftThree = () => {
  const charRef = useRef(null)

  useEffect(() => {
    initChart()
  }, [])

  const initChart = () => {
    const chart = echarts.init(charRef.current)

    chart.setOption({
      tooltip: {
        trigger: 'item',
      },
      legend: {
        left: '5%',
        top: '0',
        bottom: '0%',
        textStyle: {
          color: '#fff',
        },
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: ['40%', '70%'],
          avoidLabelOverlap: false,
          center: ['50%', '60%'],
          label: {
            show: false,
            position: 'center',
          },
          emphasis: {
            label: {
              show: true,
              fontSize: 40,
              fontWeight: 'bold',
            },
          },
          labelLine: {
            show: false,
          },
          data: [
            { value: 148, name: '小区' },
            { value: 35, name: '医疗' },
            { value: 5, name: '学校' },
            { value: 84, name: '休闲' },
            { value: 30, name: '交通' },
            { value: 10, name: '市场' },
          ],
        },
      ],
    })
  }
  return (
    <div className="left-two">
      <div className="box-title">社区周边资源配置</div>
      <div className="box-content left-three-content dis-flex">
        <div
          className="char flex1"
          ref={charRef}
          style={{ height: '100%', width: '100%' }}
        ></div>
        <div className="category-list flex1 dis-flex">
          <div className="category-item line">
            <div className="category-title">
              <div className="key">小区数量</div>
              <div className="value">148</div>
            </div>
            <div className="category-title">
              <div className="key">小区数量</div>
              <div className="value">148</div>
            </div>
            <div className="category-title">
              <div className="key">小区数量</div>
              <div className="value">148</div>
            </div>
          </div>
          <div className="category-item">
            <div className="category-title">
              <div className="key">小区数量</div>
              <div className="value">148</div>
            </div>
            <div className="category-title">
              <div className="key">小区数量</div>
              <div className="value">148</div>
            </div>
            <div className="category-title">
              <div className="key">小区数量</div>
              <div className="value">148</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}

export default LeftThree
